package com.sup.model;

import javax.persistence.Cacheable;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.sup.common.BaseModel;

@Entity
@Table(name="production")
@Cacheable
@Cache(usage=CacheConcurrencyStrategy.TRANSACTIONAL,include="non-lazy")
public class Production extends BaseModel{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private Long id;
	
	@Column(name="production_type_id")
	private Long productionTypeId;
	
	@Column(name="production_name")
	private String productionName;
	
	private String description;
	
	private double price;
	
	@Column(name="repertory_amount")
	private Long repertoryAmount;
	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}


	public Long getProductionTypeId() {
		return productionTypeId;
	}

	public void setProductionTypeId(Long productionTypeId) {
		this.productionTypeId = productionTypeId;
	}

	public String getProductionName() {
		return productionName;
	}

	public void setProductionName(String productionName) {
		this.productionName = productionName;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public double getPrice() {
		return price;
	}

	public void setPrice(double price) {
		this.price = price;
	}

	public boolean compareTo(Production production) {
		if(this.productionTypeId!=production.getProductionTypeId())
			return true;
		if(this.getProductionName()==null){
			if(production.getProductionName()!=null)
				return true;
		}else {
			if(!this.getProductionName().equals(production.getProductionName()))
				return true;
		}
		if(this.getDescription()==null){
			if(production.getDescription()!=null)
				return true;
		}else {
			if(!this.getDescription().equals(production.getDescription()))
				return true;
		}
		if(this.price!=production.getPrice())
			return true;
		return false;
	}

	public Long getRepertoryAmount() {
		return repertoryAmount;
	}

	public void setRepertoryAmount(Long repertoryAmount) {
		this.repertoryAmount = repertoryAmount;
	}
	

}
